package set_map.leetcode;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @author shkstart
 *
 * 牛客的坏键盘
 * @create 2022-11-01-22:45
 */
public class BadKeyBoard {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
//        期望输入
        String expectedStr = null;
//        实际输入
        String actualStr = null;
        while(scanner.hasNext()){
            expectedStr = scanner.next();
            actualStr = scanner.next();
        }
//        将所有字符转为大写
        expectedStr = expectedStr.toUpperCase();
        actualStr = actualStr.toUpperCase();

//        使用Set存储实际输入的字符
        Set<Character> actualSet = new HashSet<>();
//        遍历期望字符串，所谓的坏键就是Set中不存在而期望中有的字符串

//        过滤重复元素
        Set<Character> expectedSet = new HashSet<>();
        for (int i = 0; i < actualStr.length(); i++) {
            actualSet.add(actualStr.charAt(i));
        }
        for (int i = 0; i < expectedStr.length(); i++) {
                char c= expectedStr.charAt(i);
            if(!actualSet.contains(c)){

                //        过滤重复元素
                if(expectedSet.add(c)){
                    System.out.print(c);

                }
            }
        }
        System.out.println();
    }

}
